<?php

namespace Biz\service\miniProgram;

use Biz\model\activity\NewCommerExclusive as mNewCommerExclusive;
use Biz\service\Goods;
use Biz\tools\IsTestShop;

class HotSales
{
    /**
     * @desc 商城小程序热销商品
     * @note
     */
    public static function main()
    {
        $goodsList = [];
        $count = mNewCommerExclusive::getActiveCount();
        $limit = 100;
        $totalPage = ceil($count / $limit);
        $result = [];
        for ($i = 0; $i < $totalPage; $i++) {
            $rs = mNewCommerExclusive::getActiveList([$i * $limit, $limit]);
            $result = array_merge($result, $rs);
        }
        if ($result) {
            $goodsIds = array_column($result, 'goods_id');

            //获取商品信息
            $goodsInfo = Goods::Goods($goodsIds);
            foreach ($goodsInfo as $value) {
                if(!IsTestShop::isTestShop($value['shop_id'])) {
                    $goodsList[] = $value;
                };
            }
        }
        return $goodsList;
    }



}